﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace NewsMine.Configuration
{
    public static class ConfigurationManager
    {



        static Dictionary<string, string> appSettings = new Dictionary<string, string>();

        static ConfigurationManager()
        {
            //todo: here the values are feeded for testing, 
            //need to read from the configuragion.
            //appSettings.Add(CommonConstants.StorageBaseFolder, @"c:\temp\DataStore\");

            //appSettings.Add("LuceneBasedStorage.StorageRootFolder", @"c:\temp\lucenestore\");

        }



        public static string Get(string key)
        {
            return  System.Configuration.ConfigurationManager.AppSettings.Get(key);
            //return appSettings[key];
        }

        static string storageBaseFolder = null;

        public static string StorageBaseFolder
        {
            get
            {
                if (string.IsNullOrEmpty(storageBaseFolder))
                {
                    storageBaseFolder = Get(CommonConstants.StorageBaseFolder);
                }

                return storageBaseFolder;
            }
        }

        static string queuesBaseFolder = null;
        public static string QueuesBaseFolder
        {
            get
            {
                if (queuesBaseFolder == null)
                {
                    queuesBaseFolder = Path.Combine(StorageBaseFolder, CommonConstants.QueuesSubDirectoryName);
                }
                return queuesBaseFolder;
            }
        }

        static string keyValueStoreBaseFolder = null;
        public static string KeyValueStoreBaseFolder
        {
            get
            {
                if (keyValueStoreBaseFolder == null)
                {
                    keyValueStoreBaseFolder = Path.Combine(StorageBaseFolder, CommonConstants.KeyValueStoreSubFolder);
                }
                return keyValueStoreBaseFolder;
            }
        }

        static string indexesBaseFolder = null;
        public static string IndexesBaseFolder
        {
            get
            {
                if (indexesBaseFolder == null)
                {
                    indexesBaseFolder = Path.Combine(StorageBaseFolder, CommonConstants.IndexesSubDirectoryName);
                }
                return indexesBaseFolder;
            }
        }


    }
}
